package com.example.dakotanews.dto;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.dakotanews.entity.News;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @description 新闻数据传输对象，将表示时间的字段进行了格式化处理
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("news")
public class NewsDetailDTO {

    @TableId(type = IdType.AUTO)
    private Integer id;
    private Integer userId;
    private Integer sortId;
    private String title;
    private String cover;
    private String summary;
    private String content;
    private int supportNum;
    private int oppositionNum;
    private int collectionNum;
    private int pageView;
    private int issueNum;
    private String publishTime;
    private String editTime;
    private int status;

    public NewsDetailDTO(News news) {
        this.id = news.getId();
        this.userId = news.getUserId();
        this.sortId = news.getSortId();
        this.title = news.getTitle();
        this.cover = news.getCover();
        this.summary = news.getSummary();
        this.content = news.getContent();
        this.supportNum = news.getSupportNum();
        this.oppositionNum = news.getOppositionNum();
        this.collectionNum = news.getCollectionNum();
        this.pageView = news.getPageView();
        this.issueNum = news.getIssueNum();
        this.status = news.getStatus();
    }
}
